package View;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.management.Query;
import javax.swing.*;

import DAO.QueryByName;
import DAO.QueryByNo;

public class QueryFrame extends JFrame {
	private JPanel contentPane = new JPanel();
	private JComboBox cmbType;
	private JLabel lab_Tip;
	private JButton btn_Query, btn_Exit;

	public QueryFrame() {
		setTitle("查询成绩");
		setSize(300, 300);
		setLocationRelativeTo(null);
		setContentPane(contentPane);
		contentPane.setLayout(null);

		lab_Tip = new JLabel("请选择查询类型:");
		lab_Tip.setBounds(80, 10, 120, 80);
		lab_Tip.setFont(new Font("宋体", Font.PLAIN, 16));
		
		String type[] = { "   按学号查询", "   按姓名查询" };
		cmbType = new JComboBox(type);
		cmbType.setFont(new Font("宋体", Font.PLAIN, 16));
		cmbType.setBounds(70, 70, 150, 30);

		btn_Query = new JButton("查询");
		btn_Query.setFont(new Font("宋体", Font.BOLD, 16));
		btn_Query.setBounds(50, 130, 70, 40);
		/*点击按钮进行查询*/
		btn_Query.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (cmbType.getSelectedItem().equals("   按学号查询")) {
					new QueryByNo();
					setVisible(false);
				} else {
					new QueryByName();
				}
			}
		});
		
		btn_Exit = new JButton("退出");
		btn_Exit.setFont(new Font("宋体", Font.BOLD, 16));
		btn_Exit.setBounds(170, 130, 70, 40);
		btn_Exit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setVisible(false);
			}
		});

		contentPane.add(lab_Tip);
		contentPane.add(cmbType);
		contentPane.add(btn_Query);
		contentPane.add(btn_Exit);

		setVisible(true);
	}
}
